package com.lgh.hotel.controller;

import com.lgh.hotel.common.aop.LogAnnotation;
import com.lgh.hotel.dao.pojo.RoomType;
import com.lgh.hotel.service.RoomTypeService;
import com.lgh.hotel.vo.Result;
import com.lgh.hotel.vo.params.RoomTypeParams;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "房间类型模块")
@RestController
@RequestMapping("roomType")
public class RoomTypeController {

    @Autowired
    RoomTypeService roomTypeService;

    @ApiOperation(value = "获取所有房间类型")
    @GetMapping
    public Result roomType(){
        return roomTypeService.findRoomTypeAll();
    }

    @ApiOperation(value = "获取此房型的所有房间（未住人）")
//    @ApiImplicitParam(name = "id",required = true,dataType = "Long")
    @GetMapping("/find/{id}")
    public Result findId(@PathVariable("id") Long id){
        return roomTypeService.findRoomTypeByIdAll(id);
    }

    @LogAnnotation
    @ApiOperation("增加房型")
    @PostMapping("/addRoomType")
    public Result addRoomType(@RequestBody RoomTypeParams roomTypeParams){
        return roomTypeService.addRoomType(roomTypeParams);
    }

    @LogAnnotation
    @ApiOperation("删除房型")
    @DeleteMapping("/deleteRoomType")
    public Result deleteRoomType(@RequestBody RoomType roomType){
        return roomTypeService.deleteRoomType(roomType.getId());
    }

    @LogAnnotation
    @ApiOperation("更改房型")
    @PutMapping("/updateRoomType")
    public Result updateRoomType(@RequestBody RoomType roomType){
        return roomTypeService.updateRoomType(roomType);
    }

}
